import axios from '@/utils/axios'

//AttachGroupController
export const getAttachGroupPage = (pagination: Pagination, params: AttachGroup): Promise<ApiResult<Page<AttachGroup>>> => {
    return axios.get(`file/attach/group/page/${pagination.page}/${pagination.pageSize}`, { params })
}

export const postAttachGroup = (data: AttachGroup): Promise<ApiResult<null>> => {
    return axios.post(`file/attach/group`, data)
}

export const deleteAttachGroup = (id: string): Promise<ApiResult<null>> => {
    return axios.delete(`file/attach/group/${id}`)
}

//AttachController
export const getAttachListByGroupId = (groupId: string): Promise<ApiResult<Attach[]>> => {
    return axios.get(`file/attach/list/${groupId}`)
}

export const postAttach = (formData: FormData): Promise<ApiResult<Attach>>  => {
    return axios.post(`file/attach`, formData,
        {
            headers: {'Content-Type': 'multipart/form-data'}
        }
    )
}

export const deleteAttach = (id: string): Promise<ApiResult<Attach>> => {
    return axios.delete(`file/attach/${id}`)
}

export const downloadAttach = (id: string): Promise<ApiResult<null>> => {
    return axios.get(`file/attach/download/${id}`)
}
